<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>

<head>
    <base href="<%=basePath%>"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css" />
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>


<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">编辑产品信息</h4>
    </div>

    <div class="panel-body">
        <form action="kehu/addcp" enctype="multipart/form-data" id="myform" method="post"
              class="form-horizontal" role="form">
            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="linkname" class="col-md-4 control-label">产品名称</label>
                    <div class="col-md-8">
                        <input type="hidden" id="oid" name="oid" value="${cp.oid}">
                        <input type="text" id="linkname" name="linkname"
                               class="form-control" placeholder="请输入产品名称"
                               value="${cp.linkname}">
                    </div>
                </div>

                <div class="form-group col-md-6">
                    <label for="url" class="col-md-4 control-label">产品规格</label>
                    <div class="col-md-8">
                        <input type="text" id="url" name="url"
                               class="form-control" placeholder="请输入产品规格"
                               value="${cp.url}">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="info" class="col-md-4 control-label">产品描述</label>
                    <div class="col-md-8">
                        <input type="text" id="info" name="info"
                               class="form-control" placeholder="请输入产品描述"
                               value="${cp.info}">
                    </div>
                </div>

                <div class="form-group col-md-6">
                    <label for="packdesc" class="col-md-4 control-label">包装描述</label>
                    <div class="col-md-8">
                        <input type="text" id="packdesc" name="packdesc"
                               class="form-control" placeholder="请输入包装描述"
                               value="${cp.packdesc}">
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="form-group col-md-12">
                    <label for="memo" class="col-md-2 control-label">产品备注</label>
                    <div class="col-md-8">
							<textarea class="form-control" id="memo" name="memo"
                                      rows="5" placeholder="请输入产品备注">${cp.memo}</textarea>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="imgfile" class="col-md-4 control-label">产品图片</label>
                    <div class="col-md-8">

                        <input type="file" id="imgfile" name="imgfile" accept="image/*"></input>
                    </div>
                </div>
            </div>


            <div class="col-md-12">
                <div class="form-group col-md-12">
                    <div class="col-md-10  col-md-offset-2">
                        <a type="button" href="javascript:history.back()" class="btn btn-info">返回</a>
                        <button type="submit" id="editBxInformaltypebtn" class="btn btn-success">提交信息</button>
                        <button type="reset" id="resetbtn" class="btn btn-default">取消操作</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>







<script type="text/javascript">
    $(document).ajaxError(function(event,xhr) {
        if(xhr.status=="403"){//没有权限
            document.location.href = xhr.getResponseHeader("url");
        }else if(xhr.status!="200"){
            //alert("服务器错误!");
            console.log("服务器错误!");
        }
    });
</script>

</body>


<script type="text/javascript">
    $(document).ready(function() {
        $("#myform").bootstrapValidator({
            message : 'This value is not valid',
            feedbackIcons : {/*input状态样式图片*/
                valid : 'glyphicon glyphicon-ok',
                invalid : 'glyphicon glyphicon-remove',
                validating : 'glyphicon glyphicon-refresh'
            },
            fields : {
                linkname : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '名称不能为空'
                        },
                        stringLength : {
                            min : 2,
                            max : 20,
                            message : '名称长度需在2-20位'
                        },
                        remote:{
                            url:"kehu/byname",
                            delay:1000,
                            type:'post',
                            message:'名称已存在!',
                            data:function(validator){
                                return {
                                    'name':$("#linkname").val(),
                                    'oid':$("#oid").val(),
                                };
                            }
                        }
                    }
                },
                url : {
                    validators : {
                        stringLength : {
                            max : 20,
                            message : '产品规格输入过长'
                        }
                    }
                },
                info : {
                    validators : {
                        stringLength : {
                            max : 100,
                            message : '产品描述输入过长'
                        }
                    }
                },
                packdesc : {
                    validators : {
                        stringLength : {
                            max : 100,
                            message : '包装描述输入过长'
                        }
                    }
                },
                memo : {
                    validators : {
                        stringLength : {
                            max : 500,
                            message : '备注输入过长'
                        }
                    }
                }
            },
            submitHandler : function(validator,form, submitButton) {
                validator.defaultSubmit();
            }
        });


        $("#resetbtn").click(function() {
            $("#myform").data("bootstrapValidator").resetForm();
        });
    });



</script>
</html>
